// leetcode 1266 easy

package main

func minTimeToVisitAllPoints(points [][]int) int {

	var total = 0

	for index := 1; index < len(points); index++ {
		lastP := points[index-1]
		nextP := points[index]
		leftSub := nextP[0] - lastP[0]
		if leftSub < 0 {
			leftSub = -leftSub
		}
		rightSub := nextP[1] - lastP[1]
		if rightSub < 0 {
			rightSub = -rightSub
		}

		if leftSub < rightSub {
			total = total + rightSub
		} else {
			total = total + leftSub
		}

	}

	return total
}
